<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
    <title>工作人员管理</title>
    <meta name="decorator" content="default"/>
    <link href="${ctxStatic}/static_back/css/public.css" type="text/css" rel="stylesheet">
    <link href="${ctxStatic}/static_back/css/main.css" type="text/css" rel="stylesheet">
</head>

<body>
    <%--标题--%>
    <div class="top-section">
        <h2>工作人员管理</h2>
    </div>

    <div class="body-section white-body">
        <%--功能区--%>
        <form:form id="searchForm" modelAttribute="airWorker" action="${ctx}/air/airWorker/" method="post" >
            <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
            <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
            <div class="function-box">
                <div class="left-function">
                    <form:input id="search_name" path="name" htmlEscape="false" class="function-ipt" placeholder="输入姓名查询" />
                    <form:select id="airRidePointIds" path="airRidePoint.id">
                        <form:option value="" label="全部服务站点"/>
                        <form:options items="${ridePoints}" itemValue="id" itemLabel="name"/>
                    </form:select>
                    <input id="btnSubmit" class="btn btn-main" type="submit" value="查询"/>
                </div>
                <div class="right-function">
                    <shiro:hasPermission name="air:airWorker:edit">
                    <a href="${ctx}/air/airWorker/form" class="btn btn-blue">新增工作人员</a>
                    </shiro:hasPermission>
                </div>
            </div>
        </form:form>
        <sys:message content="${message}"/>

        <%--表格区--%>
        <div class="table-box">
            <table id="contentTable">
                <thead>
                <tr>
                    <th colspan="5" class="td-bb td-rb">基本信息</th>
                    <th colspan="2" class="td-bb td-rb">配置信息</th>
                    <shiro:hasPermission name="air:airWorker:edit">
                        <th rowspan="2" width="14%">操作</th>
                    </shiro:hasPermission>
                </tr>
                <tr>
                    <th width="10%">姓名</th>
                    <th width="">身份证</th>
                    <th width="10%">联系电话</th>
                    <th width="10%">对讲机</th>
                    <th width="12%" class="td-rb">应用账号</th>
                    <th width="18%">服务站点</th>
                    <th width="10%" class="td-rb">管理车辆</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach items="${page.list}" var="airWorker">
                    <tr>
                        <td>
                            <a href="javascript:void(0)" onclick="alertAir(${airWorker.id},${airWorker.airRidePoint.id})">
                                    ${airWorker.name}
                            </a>
                        </td>
                        <td>
                                ${airWorker.idNumber}
                        </td>
                        <td>
                                ${airWorker.phone}
                        </td>
                        <td>
                                ${airWorker.interphone}
                        </td>
                        <td class="td-rb">
                                ${airWorker.username}
                        </td>
                        <td>
                                ${airWorker.airRidePoint.name}
                        </td>
                        <td class="td-rb">
                                ${airWorker.airRidePoint.busSum}辆
                        </td>
                        <td class="td-center">
                            <shiro:hasPermission name="air:airWorker:edit">
                                <a href="javascript:void(0)" class="font-link" onclick="alertAir(${airWorker.id},${airWorker.airRidePoint.id})">详情</a>
                                <a href="${ctx}/air/airWorker/form?id=${airWorker.id}" class="font-link">修改</a>
                                <a href="${ctx}/air/airWorker/delete?id=${airWorker.id}"
                                   onclick="return confirmx('确认要删除该工作人员吗？', this.href)" class="font-link">删除</a>
                            </shiro:hasPermission>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
            <div class="pagination table-pagination">${page}</div>
        </div>
    </div>

    <%--详情弹窗--%>
    <div id="detailDiv" class="window-layer window-details">
        <div class="window-bg"></div>
        <div class="window-main">
            <div class="window-body">

                <%--主要信息--%>
                <div class="details-div">
                    <h3 id="aw_name"></h3>
                    <div class="info-box">
                        <ul class="info-list">
                            <li class="info-icon-id" title="身份证">
                                <span id="aw_idNumber"></span>
                            </li>
                            <li class="info-icon-building" title="所属单位">
                                <span id="aw_belongUnit"></span>
                            </li>
                            <li class="info-icon-phone" title="联系电话">
                                <span id="aw_phone"></span>
                            </li>
                            <li class="info-icon-talk" title="对讲机">
                                <span id="aw_interphone"></span>
                            </li>
                        </ul>
                    </div>
                    <div class="info-box">
                        <h4>应用账号信息</h4>
                        <ul class="info-list">
                            <li class="info-icon-account" title="账号">
                                <span id="username"></span>
                            </li>
                            <li class="info-icon-psw" title="密码">
                                <span id="password"></span>
                            </li>
                        </ul>
                    </div>
                    <div class="info-box">
                        <h4>服务站点信息</h4>
                        <ul class="info-list">
                            <li class="info-icon-home" title="乘车点">
                                <span id="arp_name"></span>
                            </li>
                            <li class="info-icon-person" title="乘车点负责人">
                                <span id="arp_leader"></span>&nbsp&nbsp
                                <span id="arp_phone"></span>
                            </li>
                            <li class="info-icon-position" title="乘车点位置">
                                <span id="arp_position"></span>
                            </li>
                            <li class="info-icon-car" title="乘车点专线车辆数">
                                <span id="arp_busSum"></span> 辆专线车辆
                            </li>
                        </ul>
                    </div>
                    <div class="window-bottom">
                        <input type="button" class="btn" value="关闭" onclick="CloseDiv()"/>
                    </div>
                </div>
            </div>
        </div>
    </div>


    <script type="text/javascript">
        function alertAir(id, airRidePointId) {
            $.ajax({
                url: "${ctx}/air/airWorker/getDetail",
                type: "GET",
                data: {id: id, airRidePointId: airRidePointId},
                success: function (data) {
                    var airWorker = data["airWorkerData"];
                    $("#aw_name").html(airWorker.name);
                    $("#aw_idNumber").html(airWorker.idNumber);
                    $("#aw_belongUnit").html(airWorker.belongUnit);
                    $("#aw_phone").html(airWorker.phone);
                    $("#aw_interphone").html(airWorker.interphone);
                    $("#username").html(airWorker.username);
                    $("#password").html(airWorker.password);
                    var airRidePoint = data["airRidePointData"];
                    $("#arp_name").html(airRidePoint.name);
                    $("#arp_position").html(airRidePoint.position);
                    $("#arp_leader").html(airRidePoint.leader);
                    $("#arp_phone").html(airRidePoint.phone);
                    $("#arp_busSum").html(airRidePoint.busSum);
                }
            });
            $("#detailDiv").css("display", "block");
        }

        function page(n, s) {
            $("#pageNo").val(n);
            $("#pageSize").val(s);
            $("#searchForm").submit();
            return false;
        }

        function CloseDiv() {
            $("#detailDiv").css("display", "none");
        }
    </script>

</body>
</html>